home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Developers / CW Examples / hello.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-24  |  1.4 KB  |  59 lines  |  [TEXT/KAHL]

  1. /* ========== the commmand file: ==========
  2.  
  3.     hello.c - an examle of a simple nShell(tm) command.
  4.     
  5.     Copyright (c) 1993,1994 Newport Software Development
  6.     
  7.     You may distribute unmodified copies of this file for
  8.     noncommercial purposes.  You may use this file as a
  9.     reference when writing your own nShell(tm) commands.
  10.     
  11.     All other rights are reserved.
  12.     
  13.    ========== the commmand file: ========== */
  14.  
  15. #ifdef __MWERKS__            // CodeWarrior requires an A4 setup
  16. #include <A4Stuff.h>
  17. #endif
  18.  
  19. #include "nshc.h"
  20.  
  21. #include "nshc_utl.proto.h"
  22.  
  23. void main(t_nshc_parms *nshc_parms, t_nshc_calls *nshc_calls)
  24. {
  25. #ifdef __MWERKS__
  26.     long oldA4  = SetCurrentA4();
  27. #endif
  28.     
  29.     // exit if the version of our nshc.h does not match the one the application used.
  30.     // We use "goto Exit" rather than "return" to make sure A4 is restored properly
  31.  
  32.     if (nshc_bad_version( nshc_parms, nshc_calls, NSHC_VERSION )) goto Exit;
  33.     
  34.     // otherwise, handle requests from the application
  35.  
  36.       switch (nshc_parms->action) {
  37.         case nsh_start:
  38.         case nsh_continue:
  39.             nshc_calls->NSH_printf("Hello World\r");
  40.             break;
  41.         case nsh_idle:
  42.         case nsh_stop:
  43.             break;
  44.         }
  45.         
  46.     // tell the application we are done - for any requested action
  47.  
  48.      nshc_parms->action = nsh_idle;
  49.     nshc_parms->result = NSHC_NO_ERR;
  50.  
  51. Exit:
  52.  
  53. #ifdef __MWERKS__
  54.     SetA4(oldA4);        // CodeWarrior needs to restore A4
  55. #else
  56.     ;                    // Think needs a ; to go with the Exit label
  57. #endif
  58. }
  59.